From 9e18a521569341486156c75db488e35e16904616 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 16 Nov 2013 14:49:21 -0500 Subject: [PATCH] Fix fallback menubar size allocation When the menubar inserted by GtkApplicationWindow is the widest widget in a csd window, its allocation gets cut short. Fix this by taking the decoration size into account while calculating the size request (it is implicitly taken into account in the size allocation phase by _gtk_window_set_allocation). --- gtk/gtkapplicationwindow.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gtk/gtkapplicationwindow.c b/gtk/gtkapplicationwindow.c index 9c3d1ba36f..079f4bbdb2 100644 --- a/gtk/gtkapplicationwindow.c +++ b/gtk/gtkapplicationwindow.c @@ -547,8 +547,17 @@ gtk_application_window_real_get_preferred_width (GtkWidget *widget, if (window->priv->menubar != NULL) { gint menubar_min_width, menubar_nat_width; + gint border_width; + GtkBorder border = { 0 }; gtk_widget_get_preferred_width (window->priv->menubar, &menubar_min_width, &menubar_nat_width); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border); + + menubar_min_width += 2 * border_width + border.left + border.right; + menubar_nat_width += 2 * border_width + border.left + border.right; + *minimum_width = MAX (*minimum_width, menubar_min_width); *natural_width = MAX (*natural_width, menubar_nat_width); } @@ -574,8 +583,17 @@ gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget, if (window->priv->menubar != NULL) { gint menubar_min_width, menubar_nat_width; + gint border_width; + GtkBorder border = { 0 }; gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, &menubar_nat_width); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border); + + menubar_min_width += 2 * border_width + border.left + border.right; + menubar_nat_width += 2 * border_width + border.left + border.right; + *minimum_width = MAX (*minimum_width, menubar_min_width); *natural_width = MAX (*natural_width, menubar_nat_width); } -- 2.30.2